#include <iostream>
#include <vector>
using namespace std;
vector<int> value;
vector<int> weight;
vector<int> counti;    
int n, W;
int func() {
    vector<int> all_weight;
    vector<int> all_value;
    for(int i = 0; i < n; i++) {
        int v = value[i];
        int w = weight[i];
        int k = counti[i];
        for(int j = 1; k > 0; j*=2) {
            int temp = min(j, k);
            all_value.push_back(v * temp);
            all_weight.push_back(w * temp);
            k -= temp; // 太阴间了
        }
    }
    vector<int> dp(W + 1, 0);
    for(int i = 0; i < all_value.size(); i++) {
        for(int j = W; j >= all_weight[i]; j--) {
            dp[j] = max(dp[j], dp[j - all_weight[i]] + all_value[i]);
        }
    }
    return dp[W];
}
int main() {
    cin >> n >> W;
    for(int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        value.push_back(x);
        weight.push_back(y);
        counti.push_back(z);
    }
    cout << func() << endl;
    return 0;
}